<?php
	class file_function{
		public $cafe_name;
		public $filename;
		public $path;
		
		function file_function(){
			$this->path = dirname(BASEPATH) . '/application/controllers/';			
		}
		
		function check_inreserve_filename($name){
			$data = array('admin','article','cafe','index','member','register','test');
			if (in_array(strtolower($name), $data, true))
				return false;
			else
				return true;
		}
		function create_file(){
			if (file_exists($this->path .$this->filename))
				unlink($this->path . $this->filename);
				
			$file = fopen($this->path . $this->filename, 'w');

			$success = false;
			if ($file)
				$success = true;

			$content = '<?php require_once dirname(BASEPATH) . "/application/controllers/system/abs_page.php";';	
			$content .= 'class ' . $this->cafe_name . ' extends abs_page {} ?>';
			
			if ($this->cafe_name == ''){
				fclose($file);
				return false;
			}		
			
			fwrite($file, $content);			
			fclose($file);
			
			return $success;
		}
	}